<?php
namespace app\index\model;

use think\Model;
use think\DB;

class SignIn extends Model
{
    public function addSignIn($uid){
        $res = DB::name('sign_in')->where('uid',$uid)->find();
        if(empty($res)){
            $map = [
                'uid' => $uid,
                'signintime' => time(),
                'times' => 1,
            ];
            return DB::name('sign_in')->insert($map);
        }else{
            if( date('j',time()-$res['signintime'])<=1 ){
                return 0;
            }else{
                return DB::name('sign_in')->where('uid',$uid)->setInc('times');
            }
        }
    }
}